---
title: Lazy retrieval of policy detail and indicators
summary: Fetches detail-backed fields (waiver flag, detail record, secondary status, coverage-bound flag, info-page-printed flag, coverage gaps) on demand.
status: draft
owner: SAIF Corporation
last_reviewed: 2026-09-01
library: SAIF.Business.View.Policy
reference_type: embedded
operation_id: op-02-lazy-retrieve-policy-detail
trigger: Consumer reads a detail-backed property on clsPolicyData
---

# Lazy retrieval of policy detail and indicators

Defers a set of expensive per-policy lookups (waiver existence, extended detail record, secondary status, coverage-bound flag, information-page-printed flag, coverage gaps) until the corresponding property is first read, rather than loading them during `GetPolicyData`.

| Field | Value |
| --- | --- |
| **Operation ID** | op-02-lazy-retrieve-policy-detail |
| **Trigger** | Consumer reads a detail-backed property (e.g. `HasWaiver`, a detail field, `GetCoverageBoundFlag`, `IsInformationPagePrinted`) |
| **Inputs** | Policy number (from the already-retrieved `clsPolicyData`) |
| **Outputs** | Detail fields, flags |
| **Primary components** | `LazyRead`, `RetrieveHasWaiver`, `RetrievePolicyDetail`/`FillDetail`, `GetSecondaryPolicyStatus`, `GetCoverageBoundFlag`, `IsInformationPagePrinted` |
| **Entry point** | `SAIF.Business.View.Policy/clsPolicyData.vb` |

## Steps

1. A property getter (there are ~10 detail-backed properties in `clsPolicyData`) calls `LazyRead(LazyReadRequest.PolicyDetail)` or `LazyRead(LazyReadRequest.HasWaiver)` before returning its backing field.
2. `LazyRead` dispatches on the request type:
   - `HasWaiver` → `RetrieveHasWaiver()` (no exception handling — a failure here propagates to the caller).
   - `PolicyDetail` → `RetrievePolicyDetail()`, wrapped in a `Try/Catch` that silently swallows all exceptions ([BR-VP-026](../business-rules.md#br-vp-026-detail-read-failure-does-not-fail-overall-retrieve)).
3. `RetrieveHasWaiver`: guarded by `m_WaiverRead` (read-once flag); opens a portal request, sets `CommandType = StoredProcedure`, `RequestType = Scalar`, `SQLStatement = MyCriteria.HasWaiverSQL` ([SQL-012](../sql/SQL-012-get-policy-waiver-count.md), procedure `Pk82033_ThirdParty.get_policy_waiver_count`), binds `PolicyNum` and a `WaiverCount` return-value parameter, processes the request, and casts the return value to `Boolean` via `CBool`.
4. `RetrievePolicyDetail`: guarded by `m_PolicyDetailRead`; opens a portal request with `RequestType = Reader`, `SQLStatement = MyCriteria.RetrieveDetailSQL` ([SQL-011](../sql/SQL-011-getviewdetail.md), procedure `pk72846_view_policy.getviewdetail`), binds `apolicynum` and a cursor parameter, and sets `AfterRequestMethod = AddressOf FillDetail` so the framework invokes `FillDetail` once the request completes.
5. `FillDetail` reads the first row (if the reader is not closed) and hydrates ~20 detail fields (`m_ChapterCode`, `m_ComboWrapSubFlag`, `m_CurrentBalance`, date fields converted via `clsSmartDate`, `m_NaicsCode`/`m_NaicsDescr`, `m_SicCode`, etc.) directly from named reader columns.
6. `GetSecondaryPolicyStatus` (invoked by another lazily-backed property, not gated by a `LazyRead` flag) executes `MyCriteria.GetSecondaryPolicyStatusSQL` ([SQL-015](../sql/SQL-015-secondary-policy-status.md)) as `CommandType.Text`/`Scalar`, binding `in_policy_num`, and trims the scalar result — an empty string if the result is null.
7. `GetCoverageBoundFlag` only runs its query if `PolicyPeriods.Count > 0` (short-circuits otherwise). It executes `MyCriteria.GetCoverageBoundFlagSQL` ([SQL-016](../sql/SQL-016-coverage-bound-flag.md)) as `Text`/`Scalar`, binding `in_policy_num` and `in_policy_period_eff_date` from `GetCurrentPolicyPeriod().PolicyPeriodEffDate` (see [Retrieve policy periods](op-03-retrieve-policy-periods.md)), and returns `True` only if the trimmed result equals `"Y"`.
8. `IsInformationPagePrinted(policyNum, effDate)` executes `MyCriteria.GetIsInformationPagePrintedSQL` ([SQL-017](../sql/SQL-017-info-page-printed.md), procedure `SP72347_INFO_PAGE_PRINTED_YN`) as `CommandType.StoredProcedure`/`Scalar`, binding `in_policy_num`, `in_policy_period_eff_date`, and an `out_flag` return-value parameter; returns `True` only if the flag equals `"Y"`.
9. Coverage gaps ([SQL-018](../sql/SQL-018-getgaps.md), procedure `pk72846_view_policy.getgaps`) are exposed through a similarly lazily-triggered accessor that was not directly located in this pass — cross-referenced from the hub catalog only.**

## Process flow

```mermaid
flowchart TD
	Start(["Property getter reads<br>a detail-backed field"]) --> A["LazyRead dispatches<br>on request type"]
	A -->|HasWaiver| B["RetrieveHasWaiver:<br>scalar query, get_policy_waiver_count"]
	A -->|PolicyDetail| C["RetrievePolicyDetail:<br>reader query, getviewdetail"]
	B --> D["m_Waiver flag set,<br>m_WaiverRead = True"]
	C --> E{Try succeeds?}
	E -->|Yes| F["FillDetail hydrates<br>detail fields"]
	E -->|No| G["Exception swallowed,<br>fields remain default"]
	F --> H["m_PolicyDetailRead = True"]
	G --> H
	D --> End(["Return requested field"])
	H --> End
```

## Failure and edge-case behavior
- `RetrievePolicyDetail` failures are caught and discarded — the caller sees default field values with no indication a read failed ([BR-VP-026](../business-rules.md#br-vp-026-detail-read-failure-does-not-fail-overall-retrieve)).
- `RetrieveHasWaiver` has no exception handling — a data-access failure propagates directly to the caller of the `HasWaiver`-backed property.*
- Both `m_WaiverRead` and `m_PolicyDetailRead` are read-once flags: a caught exception in `RetrievePolicyDetail` still sets `m_PolicyDetailRead = True`, so a transient failure is never retried on a subsequent property read within the same object instance.*
- `GetCoverageBoundFlag` returns `False` (not unknown) when `PolicyPeriods.Count = 0`, which is indistinguishable from a genuine "not bound" result.*

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources
- `SAIF.Business.View.Policy/clsPolicyData.vb`
